package swing;
import java.awt.BorderLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.BorderFactory;

import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/

final class VentanaScrollBar extends javax.swing.JFrame implements AdjustmentListener {
	  JLabel etiqueta;
	  JScrollBar barra;
	  //constructor
	  public VentanaScrollBar() {
	   barra=new JScrollBar(JScrollBar.VERTICAL,0, 30,0, 300);
	   etiqueta=new JLabel("Valor: 0");
	   etiqueta.setVerticalAlignment(JLabel.CENTER);
	   getContentPane().add(barra,BorderLayout.NORTH);

	   getContentPane().add(etiqueta,BorderLayout.SOUTH);
	   barra.addAdjustmentListener(this);
	  }
	
	  public void adjustmentValueChanged(AdjustmentEvent e) {
	   etiqueta.setText("Valor: "+e.getValue());
	  }
	}

public class JFrameReporteOrdenadosNotaFinal extends javax.swing.JFrame {
	private JScrollPane jScrollPanelOrdenadosNotaFinal;
	private JTable jTableOrdenadosNotaFinal;
    JFrameCrearSeccion jfseccion = new JFrameCrearSeccion();
    JLabel etiqueta;
    private JScrollBar jScrollBarBarra;
    private JLabel lblLogo;
    private JFormattedTextField jFormattedTextFieldSeccion;
    private JButton btnListo;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrameReporteOrdenadosNotaFinal inst = new JFrameReporteOrdenadosNotaFinal();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JFrameReporteOrdenadosNotaFinal() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				
				jScrollPanelOrdenadosNotaFinal = new JScrollPane();
				{
					setTitle("Listado de Estudiantes Ordenados por Nota Final");
					this.setPreferredSize(new java.awt.Dimension(467, 364));
					getContentPane().setBackground(new java.awt.Color(255,255,255));

					TableModel jTableOrdenadosNotaFinalModel = new DefaultTableModel(
						new String[][] { { "", "" }, { "", "" },{ "", "" },{ "", "" },{ "", "" },{ "", "" }},
						new String[] { "Cedula", "Nombre","Apellido","Nota Final" });
					
					jTableOrdenadosNotaFinal = new JTable();
					jTableOrdenadosNotaFinal.setEnabled(false);
					jScrollPanelOrdenadosNotaFinal.setViewportView(jTableOrdenadosNotaFinal);
					jTableOrdenadosNotaFinal.setModel(jTableOrdenadosNotaFinalModel);
					 
					if (JFrameCrearSeccion.secc.getAlumnos().size()>0){
					    JFrameCrearSeccion.secc.ordenadosNotaFinal();
					    //Estudiante estudiante;
				        for(int i=0;i<JFrameCrearSeccion.secc.getAlumnos().size();i++){
				        	//DefaultTableModel temp1 = (DefaultTableModel) jTableOrdenadosNotaFinal.getModel();
					          //estudiante=JFrameCrearSeccion.secc.getAlumnos().elementAt(i);
					    	  jTableOrdenadosNotaFinal.setValueAt(JFrameCrearSeccion.secc.getAlumnos().elementAt(i).getCedula(),i,0);
					    	  jTableOrdenadosNotaFinal.setValueAt(JFrameCrearSeccion.secc.getAlumnos().elementAt(i).getNombre(),i,1);
					    	  jTableOrdenadosNotaFinal.setValueAt(JFrameCrearSeccion.secc.getAlumnos().elementAt(i).getApellido(),i,2);
					    	  jTableOrdenadosNotaFinal.setValueAt(JFrameCrearSeccion.secc.getAlumnos().elementAt(i).getNotaFinal(),i,3);
				        }
				    }
				    else
				      JOptionPane.showMessageDialog(null,"Listado vacio, no hay estudiantes inscritos", "Listado de Estudiantes Ordenados por Nota Final",JOptionPane.INFORMATION_MESSAGE);  	  
			}	

			pack();
			this.setSize(467, 364);
			}
			{
				jScrollBarBarra = new JScrollBar();
			}
			{
				btnListo = new JButton();
				btnListo.setIcon(new ImageIcon(getClass().getResource("salir.jpeg")));
				btnListo.setBackground(new java.awt.Color(255,255,255));
				//jbtnsalir.setText("Salir");
				btnListo.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						System.out.println("jbtnsalir.mouseClicked, event="+evt);
						
						//TODO add your code for btnEstudiante.mouseClicked
						JFrameMenu jfest = new JFrameMenu();
	    				 jfest.setLocationRelativeTo(null);
	    				 jfest.setVisible(true);
	    				 setVisible(false);
					}
				});
			}
			{
				jFormattedTextFieldSeccion = new JFormattedTextField();
				jFormattedTextFieldSeccion.setText("Nota Final");
				jFormattedTextFieldSeccion.setEditable(false);
				jFormattedTextFieldSeccion.setBackground(new java.awt.Color(24,87,227));
				jFormattedTextFieldSeccion.setForeground(new java.awt.Color(255,255,255));
				jFormattedTextFieldSeccion.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			}
			{
				lblLogo = new JLabel();
				lblLogo.setIcon(new ImageIcon(getClass().getResource("escudo.jpeg")));
			}
			     thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(lblLogo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)
				    .addGroup(thisLayout.createSequentialGroup()
				        .addGap(17)
				        .addGroup(thisLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addComponent(jFormattedTextFieldSeccion, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(32))
				            .addComponent(btnListo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE))
				        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))
				.addGap(23)
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(jScrollPanelOrdenadosNotaFinal, GroupLayout.Alignment.LEADING, 0, 222, Short.MAX_VALUE)
				    .addComponent(jScrollBarBarra, GroupLayout.Alignment.LEADING, 0, 222, Short.MAX_VALUE)));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
			     	.addGroup(thisLayout.createParallelGroup()
			     	    .addComponent(jScrollPanelOrdenadosNotaFinal, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 443, GroupLayout.PREFERRED_SIZE)
			     	    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
			     	        .addGap(26)
			     	        .addComponent(lblLogo, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
			     	        .addComponent(jFormattedTextFieldSeccion, GroupLayout.PREFERRED_SIZE, 264, GroupLayout.PREFERRED_SIZE)
			     	        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
			     	        .addComponent(btnListo, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
			     	        .addGap(39)))
			     	.addComponent(jScrollBarBarra, 0, 22, Short.MAX_VALUE));
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
